*clear
set more off

* PLEASE UPDATE THE PATHS ACCORDINGLY:
global figures ".../Data files/Figures"
global data ".../Data files/Data"
*global data "/Users/chedly/Desktop/Mortgage and discrimination/CFPB data"
global regressions ".../Data files/Regressions"
global do_dir ".../Data files/Do Files"

************ Step 1: generate main dataset from CFPB HMDA files	************


forvalues i=2007(1)2009{
use if rate_spread~=. using "$data/`i'.dta", clear
save "$data/`i'_hoepa.dta", replace
}

use "$data/2007_hoepa.dta", clear
forvalue i=2008(1)2017{
append using "data/`i'_hoepa.dta", force
}
replace as_of=2017 if as_of==.
save "$data/demog_meta.dta", replace


************ Step 2: generate the figures and tables	************

do "$do_dir/1_figure1.do"
do "$do_dir/2_figure2_panel_a_c.do"
do "$do_dir/3_figure2_panel_b_d.do"
do "$do_dir/5_figure3_panel_c_d.do"
do "$do_dir/6_figure4_panel_a_b.do"
do "$do_dir/7_figure4_panel_c_d_figure_a12.do"
do "$do_dir/8_table1_table_a2.do"
do "$do_dir/9_table_a1.do"
do "$do_dir/10_figure_a1-a4.do"
do "$do_dir/11_figure_a5_a6_panel_a.do"
do "$do_dir/12_figure_a5_a6_panel_b.do"
do "$do_dir/13_figure_a5_a6_panel_c.do" 
do "$do_dir/14_figure_a5_a6_panel_d.do"
do "$do_dir/15_figure_a7_a8_panel_a.do"
do "$do_dir/16_figure_a7_a8_panel_b.do"
do "$do_dir/17_figure_a7_a8_panel_c.do"
do "$do_dir/18_figure_a7_a8_panel_d.do"
do "$do_dir/19_figure_a9.do"
do "$do_dir/20_figure_a10.do" 
do "$do_dir/21_figure_a11.do"
do "$do_dir/22_figure_a13-a15.do"

